package com.yuntian.mapper;

import com.github.pagehelper.Page;
import com.yuntian.Dto.UserPageQueryDto;
import com.yuntian.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    /**
     * 分页查询
     * @param userPageQueryDto
     * @return
     */
    Page<User> selectUserList(UserPageQueryDto userPageQueryDto);

    /**
     * 根据用户名查询
     * @param username
     * @return
     */
    @Select("select * from user where username = #{username}")
    User selectByUsername(String username);

    /**
     * 插入用户
     * @param user
     */
    void insertUser(User user);

    /**
     * 删除用户
     * @param userId
     */
    @Select("delete from user where user_id= #{userId}")
    void deleteUser(long userId);

    /**
     * 更新用户
     * @param user
     */
    void updateUser(User user);
    @Select("select * from user where user_id = #{userId}")
    User getByUserId(Long userId);

    /**
     * 统计用户数量
     * @return
     */
    @Select("select count(*) from user")
    Integer count();
}
